package mx.com.sinformex.simbel.components;

import java.util.List;

import mx.com.sinformex.simbel.db.dao.IAdminDataAccess;
import mx.com.sinformex.simbel.db.eos.Group;
import mx.com.sinformex.simbel.db.eos.Report;
import mx.com.sinformex.simbel.pages.reports.ViewReport;
import mx.com.sinformex.simbel.utils.Session;

import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Parameter;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;

/**
 * @author Oscar Ivan Hernandez Ventura [ oscar at sinformex dot com dot mx]
 *
 * @version $ Id : Frame.java , v 1.0 10/05/2009 angellore $
 */
public class Frame {
	
	@Parameter(required=false, defaultPrefix="literal")
	@Property
	private String title;
	
	@ApplicationState
	@Property
	private Session session;
	
	@Inject
	private IAdminDataAccess adminDataAccess;
	
	@Property
	private Group group;
	@Property
	private Report report;
	@InjectPage
	private ViewReport viewReportPage;
	
	Object onActionFromLogout() {
		session = null;
		return "Index";
	}
	
	public List<Group> getGroups() {
		return adminDataAccess.fetchGroups();
	}
	
	Object onActionFromViewReport(Integer id) {
		viewReportPage.setReport(adminDataAccess.getReport(id));
		return viewReportPage;
	}

}
